package com.sirui.spider.kuai.controller;

import com.sirui.spider.kuai.entity.Kuai;
import com.sirui.spider.kuai.service.KuaiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * (Kuai)表控制层
 *
 * @author linson
 * @since 2023/07/12
 */
@Api("(Kuai)服务")
@RestController
@RequestMapping("kuai")
public class KuaiController {

    @Autowired
    private KuaiService kuaiService;

    @PostMapping("")
    @ApiOperation(value = "创建", notes = "创建")
    @ApiImplicitParam(name = "kuai", value = "", dataType = "Kuai", required = true, paramType = "body")
    public Kuai createKuai(@RequestBody Kuai kuai) {
        return kuaiService.createKuai(kuai);
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除", notes = "删除")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "id", dataType = "Integer", required = true, paramType = "path")
    })
    public void deleteKuai(@PathVariable Integer id) {
        kuaiService.deleteKuai(id);
    }

    @GetMapping("")
    @ApiOperation(value = "获取列表", notes = "获取列表")
    public List<Kuai> listKuais() {
        return kuaiService.listKuais();
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "获取", notes = "根据id获取")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "id", dataType = "Integer", required = true, paramType = "path")
    })
    public Kuai getKuai(@PathVariable Integer id) {
        return kuaiService.getKuai(id);
    }

    @PutMapping("/{id}")
    @ApiOperation(value = "更新", notes = "更新")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "id", dataType = "Integer", required = true, paramType = "path"),
            @ApiImplicitParam(name = "kuai", value = "", dataType = "Kuai", required = true, paramType = "body")
    })
    public Kuai updateKuai(@PathVariable Integer id, @RequestBody Kuai kuai) {
        return kuaiService.updateKuai(id, kuai);
    }

}
    

